<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\Resource;

class Collect extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        if($request->type < 7){
            return [
                'id'=>$this->commentable->id,
                'title'=>$this->commentable->title,
                'image'=> env('APP_IMGURL').'/model/'.$this->commentable->image,
                'created_at'=>$this->created_at->toDateString(),
            ];
        }else{
            return [
                'id'=>$this->commentable->id,
                'title'=>$this->commentable->title,
                'image'=> $this->commentable->image,
                'created_at'=>$this->created_at->toDateString(),
            ];
        }
    }
}
